﻿using Catalogo.Portable.ViewModel.Messages;
using Microsoft.Phone.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Catalogo.WindowsPhone.Views
{
    public class NavegarParaPaginaMessageHandler
    {
        public static void NavegarParaPagina(NavegarParaPagina mensagem)
        {
            var framePrincipal = App.Current.RootVisual as PhoneApplicationFrame;
            var url = string.Format("/Views/{0}.xaml?param={1}", mensagem.Pagina, mensagem.Parametro);
            framePrincipal.Navigate(new Uri(url, UriKind.Relative));
        }

        public static string ObterParametro(Uri uri)
        {
            var url = uri.OriginalString;
            var separador = "?param=";
            return url.Substring(url.IndexOf(separador) + separador.Length);
        }
    }
}
